package com.linxz.framework.presenter;

import com.linxz.framework.base.ActivityLifeCycleEvent;
import com.linxz.framework.base.presenter.BasePresenter;
import com.linxz.framework.bean.UserBean;
import com.linxz.framework.module.UserModule;
import com.linxz.framework.protocol.callback.ModelCallBack;
import com.linxz.framework.view.UserView;

import io.reactivex.subjects.PublishSubject;

/**
 * @author Linxz
 * 创建日期：2020年12月14日 15:50
 * version：
 * 描述：
 */
public class UserPresenter extends BasePresenter<UserView, UserModule> {

    public UserPresenter(UserView mView, PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        super(mView, lifecycleSubject);
    }

    @Override
    public UserModule createModel(PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        return new UserModule(lifecycleSubject);
    }


    public void login(String mobile,String password){
        mModel.login(mobile, password, new ModelCallBack<UserBean>() {
            @Override
            public void onSuccess(UserBean model) {
                mView.loginSuccess();
            }

            @Override
            public void onErrors(String code, String msg) {
                mView.loginError(msg);
            }
        });
    }
}
